//
//  CPStatusCell.swift
//  weibo
//
//  Created by zcp on 16/5/16.
//  Copyright © 2016年 zcp. All rights reserved.
//

import UIKit

class CPStatusCell: UITableViewCell {

    //模型属性
    var status: CPStatus? {
    
        didSet{
        
            originalView.status = status
        }
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        backgroundColor = UIColor.lightGrayColor()
        prepareUI()
    }
    //MARK: - 添加子控件和约束
    private func prepareUI(){
        //添加原创view
        contentView.addSubview(originalView)
        contentView.addSubview(bottomView)
        //添加约束
        originalView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentView).offset(10)
            make.trailing.leading.equalTo(contentView)
//            let height = Int( arc4random_uniform(300)+50)
//            make.height.equalTo(height)
//            make.bottom.equalTo(contentView)
            
        }
        
        bottomView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(originalView.snp_bottom)
            make.leading.trailing.equalTo(contentView)
            make.height.equalTo(37)
        }
        //约束contentview
        contentView.snp_makeConstraints { (make) -> Void in
            make.top.leading.trailing.equalTo(self)
            make.bottom.equalTo(bottomView)
        }
    
    }
    //MARK: - 懒加载
    //原创view
    private lazy var originalView: CPStatusOriginalView = CPStatusOriginalView()
    //转发,赞,评论下部view
    private lazy var bottomView: CPStatusBottomView = CPStatusBottomView()}
